//
//  BarberAlertView.m
//  HeadYang
//
//  Created by sunmingming on 15/7/22.
//  Copyright (c) 2015年 xiaoluoli. All rights reserved.
//

#import "BarberAlertView.h"

@interface BarberAlertView ()

-(void)okPressed:(id)sender;
-(void)caPressed:(id)sender;

@end

@implementation BarberAlertView

//-1 failed 0 success 1 success for whole level
- (instancetype)init{
    //solid frame,up validition is a just frame...
    CGRect solidRect = CGRectMake(0,0,280,150);
    if(!(self = [super initWithFrame:solidRect])){
        return nil;
    }
    self.backgroundColor = [UIColor whiteColor];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 280, 100)];
    label.backgroundColor = [UIColor redColor];
    [self addSubview:label];
    
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 30, 30)];
    img.image = [UIImage imageNamed:@"booking_confirm.png"];
    [self addSubview:img];
    
    UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(46,8,200,30)];
    lab1.textColor = [UIColor whiteColor];
    lab1.text = @"预约时间";
    [self addSubview:lab1];
    
    UILabel *lab2 = [[UILabel alloc] initWithFrame:CGRectMake(46,46,200,30)];
    lab2.textColor = [UIColor whiteColor];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy年MM月dd日"];
    lab2.text = [NSString stringWithFormat:@"%@%02d时",[dateFormatter stringFromDate:APPALL.selectDate],((APPALL.startTimeFlag - 1)/4)];
    [self addSubview:lab2];
    
    UIButton *but1 = [[UIButton alloc] initWithFrame:CGRectMake(30,110, 100, 30)];
    but1.backgroundColor = [UIColor redColor];
    [but1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [but1 setTitle:@"确定" forState:UIControlStateNormal];
    [but1 addTarget:self action:@selector(okPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:but1];
    
    UIButton *but2 = [[UIButton alloc] initWithFrame:CGRectMake(150,110, 100, 30)];
    but2.backgroundColor = [UIColor redColor];
    [but2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [but2 setTitle:@"取消" forState:UIControlStateNormal];
    [but2 addTarget:self action:@selector(caPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:but2];
    
    return self;
}

-(IBAction)okPressed:(id)sender{
    [self.myDelegate alertOKPressed:nil];
}

-(IBAction)caPressed:(id)sender{
    [self.myDelegate alertCancelPressed:nil];
}

@end